<template>
  <view class="content">
    <up-input v-model="wordKey" border="surround"  prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" placeholder="请输入查询关键字"></up-input>
    <view class="uni-container">

      <uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据" @selection-change="selectionChange">
        <uni-tr>
          <uni-th width="100" align="center">书名</uni-th>
          <uni-th width="120" align="center">编号</uni-th>
          <!-- <uni-th width="100" align="center">数量</uni-th> -->
          <!-- <uni-th width="220" align="center">积分</uni-th> -->
          <uni-th align="center" >详情/编辑</uni-th>
        </uni-tr>
        <uni-tr v-for="(item, index) in tableData" :key="index">
          <!-- <uni-td align="center">{{ (pageCurrent - 1) * pageSize + index + 1 }}</uni-td> -->
          <uni-td align="center">{{ item.p1 }}</uni-td>
          <uni-td align="center">
            {{ item.p2 }}
          </uni-td>
          <!-- <uni-td align="center">{{ item.p4 }}</uni-td> -->
          <uni-td align="center">
            <view style="color:#3c9cff;" @click="goEditAndDetail">点击</view>
          </uni-td>
        </uni-tr>
      </uni-table>
      <!-- <view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize" :current="pageCurrent"
          :total="total" @change="change" /></view> -->
    </view>
    <view @click="getUse">点击1</view>
    <view @click="goLogin">点击2</view>
  </view>


</template>

<script>
import Vue from 'vue'
// import common from '../../common/common.js'
export default {
  data() {
    return {
      wordKey: '',
      title: '',
      tableData: [
        { p1: '金瓶梅1', p2: '9872', p3: '5' },
        { p1: '金瓶梅2', p2: '9872', p3: '5' },
        { p1: '金瓶梅3', p2: '9872', p3: '5' },
        { p1: '金瓶梅4', p2: '9872', p3: '5' }
      ],
      // 每页数据量
      pageSize: 10,
      // 当前页
      pageCurrent: 1,
      // 数据总量
      total: 10,
      loading: false
    }
  },
  onLoad() {
    this.getData(1);
  
   
 
  },
  methods: {
    goLogin(){
      wx.login({
          //成功放回
          success:(res)=>{
            console.log(res);
            let code=res.code
            wx.request({
      /*
          url: 'https://api.weixin.qq.com/sns/jscode2session?appid=' + APPID + '&secret=' + SECRET + '&js_code=' 
          + res.code + '&grant_type=authorization_code',
*/
          url: 'https://api.weixin.qq.com/sns/jscode2session?appid=wxf22c39814ec24440&secret=1f6378a0ec88620f0dbdef24f1bd16b7&js_code=' + res.code + '&grant_type=authorization_code',
          success:(res)=>{
            console.log(res);
            var obj = {};
              obj.openid = res.data.openid;
              obj.expires_in = Date.now() + res.data.expires_in;
            //存储openid
              wx.setStorageSync('user', obj);
            //获取到你的openid
            console.log(obj.openid);
          }
        })
          }
        })
    },
    getUse(){
       // 推荐使用wx.getUserProfile获取用户信息，开发者每次通过该接口获取用户个人信息均需用户确认，开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
    wx.getUserProfile({
      desc: '获取用户的信息',//获取用户的信息
      success:(res)=> {//用户成功授权
      console.log("成功",res)
 
      // this.setData({
      //   userInfo: res.userInfo,
      //   hasUserInfo: true,
      //   nickName:res.userInfo.nickName, //获取昵称
      //   touxian:res.userInfo.avatarUrl,  //获取头像url
      //   sex:res.userInfo.gender  //获取性别
      //     })
      },
     fail:res=>{
       console.log("失败",res)
     }
  })
    },
    goEditAndDetail() {
      uni.navigateTo({
        url: `/pages/handle`,
      });
    },
    // 分页触发
    change(e) {
      this.getData(e.current)
    },
    // 获取数据
    getData(pageCurrent, value = '') {
      this.loading = true
      this.pageCurrent = pageCurrent
      let requestData = {
        "pageNo": this.pageCurrent,
        "pageSize": this.pageSize + '',
      };
      let myThis = this;
      myThis.loading = false
      return
      common.sendRequest('POST', common.KTradeid_miniIntegralList, requestData, (data) => {


        //  4.8  3.43
        console.log('积分分页数据 =' + JSON.stringify(data));
        let res = data.data.data;
        myThis.tableData = res.list
        myThis.total = res.count


        console.log('分页数据总条目 =' + JSON.stringify(myThis.total));






      }, (data) => {




      })




    },




  }
}
</script>


<style>
.content {
  margin-left: 1vw;
  width: 98vw;
  display: flex;
  flex-direction: column;
  padding-bottom: 360px;
  /*   align-items: center;
  justify-content: center; */


}


.charts-box {


  height: 360px;
}
</style>